# buff.gd
class_name Buff
extends RefCounted  # 轻量级，无需节点

var resource: BuffResource
var target: Node
var remaining_time: float

func _init(buff_res: BuffResource, _target: Node):
	resource = buff_res
	target = _target
	remaining_time = buff_res.duration
	resource.apply_effect(target)

# 更新时间和持续效果
func process(delta: float) -> bool:
	remaining_time -= delta
	resource.update_effect(target, delta)
	return remaining_time <= 0.0

# 移除Buff
func remove():
	resource.remove_effect(target)

# 重置持续时间（用于叠加）
func reset_duration():
	remaining_time = resource.duration
